require('../../assets/css/index.less');
// 当前页面样式
require('./mybadge.less');
// 公用js
let dom=require('../../utils/dom.js');
let https=require( '../../utils/https.js' )
let local=require( '../../utils/local.js' )
dom.isLogin()
// 字体图标css
require( '../../assets/fonts/iconfont.css' )
// 引入weui
// 引入swiper的js和css
dom.ready(function(){
    // 返回上一页
   dom.get('#back').addEventListener('click',function(){
    window.history.go(-1)
   })
    // 渲染徽章数量
   let localData=local.get('userData');
    badgeNum.innerHTML = localData.ranking;
    let imgArr = [
        require('../../assets/imgs/mybadge01.jpg'),
        require('../../assets/imgs/mybadge02.jpg'),
        require('../../assets/imgs/mybadge03.jpg'),
        require('../../assets/imgs/mybadge04.jpg'),
        require('../../assets/imgs/mybadge05.jpg'),
        require('../../assets/imgs/mybadge06.jpg'),
        require('../../assets/imgs/mybadge07.jpg'),
        require('../../assets/imgs/mybadge08.jpg'),
        require('../../assets/imgs/mybadge09.jpg'),
    ];
    // 获取徽章数据
    https.get('/api/exercise/badge', {}, function (res) { 
        if (res.errno == 0) { 
            console.log(res.data);//数组对象数据
            res.data.map(v => { 
                console.log(v);
                badgesList.innerHTML += `
                <li><img src="${imgArr[v.id-1]}" alt="">${v.name}</li>
                `;
            });
            // 手动给最后一个添加固定图片
            badgesList.innerHTML += `
            <li><img src="${imgArr[imgArr.length-1]}" alt=""></li>
            `;
        }
    });
})